package com.woniu.ly.manageassembly.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.ly.model.model.Guide;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface GuideMapper extends BaseMapper<Guide> {
    @Update("UPDATE t_guide SET guide_status = #{status} WHERE guide_id = #{guideId};")
    void changeGuideStatus(@Param("guideId") int guideId,@Param("status") String status);
//    @Select("SELECT guide_id, guide_name, guide_num, guide_complain, guide_status, guide_img FROM t_guide WHERE guide_status = #{guideStatus} and guide_name  = #{guideName}")
    @Select("<script>" +
            "SELECT guide_id, guide_name, guide_num, guide_complain, guide_status, guide_img FROM t_guide" +
            "<where>" +
            "<if test = 'guideStatus!=null'>" +
            "and guide_status = #{guideStatus}" +
            "</if>" +
            "<if test = 'guideName!=null'>" +
            "and guide_name = #{guideName}" +
            "</if>" +
            "</where>" +
            "</script>")
    IPage<Guide> getGuide(Page<Guide> page, @Param("guideStatus") String guideStatus, @Param("guideName") String guideName);
}
